package com.fau.cm.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

import org.apache.commons.lang3.time.DateFormatUtils;
import org.hibernate.annotations.GenericGenerator;
import org.json.simple.JSONAware;
import org.json.simple.JSONObject;

/**
 * @desc 消息提醒表
 * @author liy
 * @datetime 2015年1月5日,下午3:14:53
 */
@Entity
@Table(name = "medical_message")
public class MedicalMessage implements Serializable, JSONAware {

	private static final long serialVersionUID = -8332407269401985774L;
	
	private String id;
	private String content;					// 内容
	private String uid;						// 接受用户ID
	private Integer isRead = 0;				// 状态0未读，1已读
	private String hospitalId;				// 企业Id
	private Date createTime = new Date();	// 创建时间
	
	@Id
	@GenericGenerator(name = "generator", strategy = "uuid.hex")
	@GeneratedValue(generator = "generator")
	@Column(name = "id", length = 32)
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@Column(name = "content", length = 255)
	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	@Column(name = "is_read", length = 1)
	public Integer getIsRead() {
		return isRead;
	}

	public void setIsRead(Integer isRead) {
		this.isRead = isRead;
	}

	@Column(name = "hospital_id", length = 32)
	public String getHospitalId() {
		return hospitalId;
	}

	public void setHospitalId(String hospitalId) {
		this.hospitalId = hospitalId;
	}

	@Column(name = "create_time")
	public Date getCreateTime() {
		return createTime;
	}


	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	@Column(name = "uid", length = 32)
	public String getUid() {
		return uid;
	}

	public void setUid(String uid) {
		this.uid = uid;
	}

	@SuppressWarnings("unchecked")
	@Override
	public String toJSONString() {
		JSONObject object = new JSONObject();
		object.put("id", id);
		object.put("uid", uid);
		object.put("content", content);
		object.put("isRead", isRead);
		object.put("hospitalId", hospitalId);
		object.put("createTime", DateFormatUtils.format(createTime, "yyyy-MM-dd HH:mm:ss"));
		return object.toString();
	}

}
